<?php

namespace App\Http\Controllers\Admin;

use App\Http\Filters\ReportEditLogFilter;
use App\Models\ReportEditLog;
use App\Http\Requests\ReportEditLogRequest;
use App\Http\Resources\ReportEditLogResource;
use Illuminate\Http\Request;

class ReportEditLogController extends Controller
{
    public function index(ReportEditLogFilter $filter)
    {
        $reportEditLogs = ReportEditLog::query()
            ->filter($filter)
            ->paginate();

        return $this->ok(ReportEditLogResource::collection($reportEditLogs));
    }

    public function create()
    {
        return $this->ok();
    }

    public function store(ReportEditLogRequest $request)
    {
        $inputs = $request->validated();
        $reportEditLog = ReportEditLog::create($inputs);

        return $this->created(ReportEditLogResource::make($reportEditLog));
    }

    public function edit(Request $request, ReportEditLog $reportEditLog)
    {
        return $this->ok(ReportEditLogResource::make($reportEditLog));
    }

    public function update(ReportEditLogRequest $request, ReportEditLog $reportEditLog)
    {
        $inputs = $request->validated();
        $reportEditLog->update($inputs);

        return $this->created(ReportEditLogResource::make($reportEditLog));
    }

    public function destroy(ReportEditLog $reportEditLog)
    {
        $reportEditLog->delete();
        return $this->noContent();
    }
}
